Mirror.prototype = new Sprite ();
/**
 * @class Mirror
 * @augments Sprite
 * @param x Xova suradnica stredu zrkadla
 * @param y Yova suradnica stredu zrkadla
 * @param normalVect Normalovy vektor na rovinu zrkadla
 * @param id Identifikator zrkadla
 * @description Trieda zachytavajuca vlastnosti zrkadla
 */
function Mirror (x,y,normalVect,id){
    //properies
    Sprite.apply (this);
    this.MirrorImage = null; 
    this.buttonMode = true;
    this.mouseChildren = false;
    this.angle =null;
    this.id = id;
    this.x = x;
    this.y = y;
    this.nVect = normalVect;
    this.clicked = false;
    //methods association
    this.init = MirrorInit;
    this.getEdges = getEdges;
}
/**
 * @class Mirror
 * @description Metoda sluziaca k inicializacii zrkadla
 */
function MirrorInit (){
    var baseNormal = new Point (0,1);
    if ((this.nVect.y > 0 && this.nVect.x < 0)||(this.nVect.y < 0 && this.nVect.x < 0)){
       this.angle =Geometry.vectorAngle(this.nVect,baseNormal );
    }
    else{
        this.angle =360-Geometry.vectorAngle(this.nVect,baseNormal ); 
    }
    var MirrorPNG =  new BitmapData("pictures/mirror.png");
    this.MirrorImage = new Bitmap (MirrorPNG);
    this.MirrorImage.x = -20;
    this.MirrorImage.y = -20;
    this.MirrorImage.mouseChildren = false;
    this.rotation = this.angle;
    this.addChild (this.MirrorImage);
}
/**
 * @class Mirror
 * @description Metoda sluziaca na vypocet krajnych bodov zrkadla
 * @return Vracia pole obsahujue dva okrajove body
 */
function getEdges(){
    var rotBaseA = Geometry.rotate(new Point(-20,0), this.angle);
    var rotBaseB = Geometry.rotate(new Point(20,0), this.angle);
    var edge1 = Geometry.vectorAddition(new Point(this.x,this.y),rotBaseA);
    var edge2 = Geometry.vectorAddition(new Point(this.x,this.y),rotBaseB);
    return [edge1,edge2];
}